package cn.lecosa.spark.prop

import java.util.Properties
import java.io.FileInputStream

object TestProp extends App{
def loadProperties():Unit = {
    val properties = new Properties()
//    val path = Thread.currentThread().getContextClassLoader.getResource("elasticsearch.properties").getPath //文件要放到resource文件夹下
    val ins=this.getClass.getClassLoader.getResourceAsStream("elasticsearch.properties")
    properties.load(ins)
//    properties.load(new FileInputStream(path))
    println(properties.getProperty("es_nodes"))//读取键为ddd的数据的值
    println(properties.getProperty("ddd","没有值"))//如果ddd不存在,则返回第二个参数
    properties.setProperty("ddd","123")//添加或修改属性值
  }
  loadProperties();
}